

function validateRegistration(vFormObject)
{
	var validateEmail=false;
	var validatePhone=false;

	var msgPrefix=" ";
	var user_msg="";
	var emailfilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i


	if(vFormObject.full_name.value=="")	user_msg= user_msg + wrap(msgPrefix + "Full Name cannot be empty. Please check.");
	if(vFormObject.rbGender_Male.checked==false && vFormObject.rbGender_Female.checked==false) user_msg= user_msg + wrap("Please select the gender Brother or Sister.");



	if(vFormObject.dob.value=="")
		user_msg = user_msg + wrap(msgPrefix + "Date of Birth cannot be empty. Please check.");
		
	else
	{
		if($("dob_Year_ID").value>=Today.getFullYear()){
			user_msg= user_msg + wrap(msgPrefix + "Invalid Date of birth. Please check.");
		}
	}


	if(vFormObject.reg_city.value=="") user_msg= user_msg + wrap(msgPrefix + "City cannot be empty. Please check.");
	if(vFormObject.reg_state.value=="") user_msg= user_msg + wrap(msgPrefix + "State cannot be empty. Please check.");
	if(vFormObject.telephone_number.value=="" && validatePhone==true) user_msg = user_msg + wrap(msgPrefix + "Telephone Number cannot be empty. Please check.");
	if(vFormObject.email_address.value=="" && validateEmail==true) user_msg = user_msg + wrap("Email address cannot be empty. Please check.");
	if(vFormObject.email_address.value!="")
	{
		if (!emailfilter.test(vFormObject.email_address.value))
			 user_msg = user_msg + wrap("Invalid Email address. Please check.");
		else{
		
			if(!$('spEmailCheck').innerHTML=="")
				user_msg = user_msg + wrap("The emailId " + vFormObject.email_address.value + " already exists in the system. Please check.");
		}
	}
	if(vFormObject.alternate_email.value!="")
	{
		if (!emailfilter.test(vFormObject.alternate_email.value)){
			user_msg = user_msg + wrap(msgPrefix + "Invalid alternate Email address. Please check.");
		}
	}
	if(vFormObject.bk_center_email.value!="")
	{
		if (!emailfilter.test(vFormObject.bk_center_email.value))
			user_msg = user_msg + wrap(msgPrefix + "Invalid BK Centre Email address. Please check.");
		
	}

	if(vFormObject.edu_qual.value=="")
		user_msg = user_msg + wrap(msgPrefix + "Educational Qualification cannot be empty. Please Check.");
	if(vFormObject.technical_specifications.value=="")
		user_msg = user_msg + wrap(msgPrefix + "Technical Specifications cannot be empty. Please check.");
	if(vFormObject.years_it_exp.value=="")
	{

		user_msg = user_msg + wrap("Please specify the experience.");
		if(!IsNumeric(vFormObject.years_it_exp.value))
		{
		//user_msg = user_msg + wrap(msgPrefix + "Please enter the years of experience in numbers.(1,1.2 etc)");
		}
		
	}

	if(vFormObject.are_you_bk_1.checked==false && vFormObject.are_you_bk_2.checked==false )
		user_msg = user_msg + wrap("if you are not a BK, please select \"No\" in Are you BK? option");
	if(vFormObject.are_you_bk_1.checked==false && vFormObject.are_you_bk_2.checked==false )	user_msg = user_msg + wrap("if you are not a BK, please select \"No\" in Are you BK? option");
	if(vFormObject.are_you_bk_1.checked==true){
		if(vFormObject.bk_center_address.value=="") user_msg= user_msg + wrap(msgPrefix + "Centre Address cannot be empty. Please check.");	
		
	}
	
	if(vFormObject.file_resume.value!=""){
	
	if(!(vFormObject.file_resume.value.indexOf(".pdf")>0 || vFormObject.file_resume.value.indexOf(".doc")>0) || vFormObject.file_resume.value.indexOf(".docx")>=0)
	
		user_msg=user_msg + "Curriculum Vitae  Resume File should be either a PDF File or Word Document File. The select file is not valid. Please Check.";
	
	}
	
	if(vFormObject.reg_technical_remark.value==""){
	
		user_msg=user_msg + "Skill set cannot be empty. Please check";
	
	}
	
	if(user_msg=="")
	{
		//$("frmSubmit").disabled=true;
		//$("frmSubmit").value="Processing please wait...";
		return true;
	}
	else
	{	
		alert(user_msg);
		return false;
	}



}



function IsNumeric(strString)
{
	var strValidChars = "0123456789.";
	var strChar;
	var blnResult = true;
	if (strString.length == 0)
		return false;
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			blnResult = false;
	}
return blnResult;
} 


function wrap(vtext)
{
return vtext + "\n" +  "\n";

}






function showLayer(vObjectName)
{

var vObject=document.getElementById(vObjectName)
vObject.style.display=''

}





function hideLayer(vObjectName)
{

var vObject=document.getElementById(vObjectName)
vObject.style.display='none'
}


function validateProfileUpdate(vFormObject){

var validateEmail=true;
	var validatePhone=false;

	var msgPrefix=" ";
	var user_msg="";
	var emailfilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if(vFormObject.full_name.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Full Name cannot be empty. Please check.");
	

	if(vFormObject.rbGender_Male.checked==false && vFormObject.rbGender_Female.checked==false)
		user_msg= user_msg + wrap("Please select the gender Brother or Sister.");
	
	if(vFormObject.dob.value=="")
		user_msg = user_msg + wrap(msgPrefix + "Date of Birth cannot be empty. Please check.");
	
	else
	{
		if($("dob_Year_ID").value>=Today.getFullYear())
			user_msg= user_msg + wrap(msgPrefix + "Invalid Date of birth. Please check.");
	
	}
	
	
	if(vFormObject.contact_address.value=="")
		user_msg= user_msg + wrap(msgPrefix + "Mailing/Contact Address cannot be empty. Please check.");
	if(vFormObject.reg_city.value=="")
		user_msg= user_msg + wrap(msgPrefix + "City cannot be empty. Please check.");
	
	
	if(vFormObject.reg_state.value=="")
		user_msg= user_msg + wrap(msgPrefix + "State cannot be empty. Please check.");
	
	
	if(vFormObject.telephone_number.value=="" && validatePhone==true)
		user_msg = user_msg + wrap(msgPrefix + "Telephone Number cannot be empty. Please check.");
	
	if(vFormObject.email_address.value=="" && validateEmail==true)		
		user_msg = user_msg + wrap("Email address cannot be empty. Please check.");
	
	if(vFormObject.email_address.value!="")
	{
		if (!emailfilter.test(vFormObject.email_address.value))
			 user_msg = user_msg + wrap("Invalid Email address. Please check.");
		else{
		
			if(!$('spEmailCheck').innerHTML==""){
				
				user_msg = user_msg + wrap("The emailId " + vFormObject.email_address.value + " already exists in the system. Please check.");
			
			}
		}
	}
	if(vFormObject.alternate_email.value!="")
	{
	
		if (!emailfilter.test(vFormObject.alternate_email.value)){
		
		user_msg = user_msg + wrap(msgPrefix + "Invalid alternate Email address. Please check.");
		
		}
	}

	
	if(vFormObject.edu_qual.value=="")
	
	user_msg = user_msg + wrap(msgPrefix + "Educational Qualification cannot be empty. Please Check.");
	
	
	if(vFormObject.technical_specifications.value=="")
	
	user_msg = user_msg + wrap(msgPrefix + "Technical Specifications cannot be empty. Please check.");
	

	
	
if(vFormObject.years_it_exp.value=="")
	{

		user_msg = user_msg + wrap("Please specify the experience.");
		if(!IsNumeric(vFormObject.years_it_exp.value))
		{
		//user_msg = user_msg + wrap(msgPrefix + "Please enter the years of experience in numbers.(1,1.2 etc)");
		}
		
	}

	if(vFormObject.are_you_bk_1.checked==false && vFormObject.are_you_bk_2.checked==false )	user_msg = user_msg + wrap("if you are not a BK, please select \"No\" in Are you BK? option");
	
	if(vFormObject.are_you_bk_1.checked==true){
	
		if(vFormObject.bk_center_address.value=="") user_msg= user_msg + wrap(msgPrefix + "Centre Address cannot be empty. Please check.");	
		
	}
	if(vFormObject.file_resume.value!=""){
	
	if(!(vFormObject.file_resume.value.indexOf(".pdf")>0 || vFormObject.file_resume.value.indexOf(".doc")>0) || vFormObject.file_resume.value.indexOf(".docx")>=0)
		user_msg=user_msg + "Curriculum Vitae  Resume File should be either a PDF File or Word Document File. The select file is not valid. Please Check.";
	
	}

	
	if(vFormObject.reg_technical_remark.value==""){
	
		user_msg=user_msg + "Skill set cannot be empty. Please check";
	
	}


	if(user_msg=="")
	{		
		return true;
	}
	else
	{	
		alert(user_msg);
		return false;
	}

	

}
function validateRegistrationFront(vFormObject)
{
	var validateEmail=true;
	var validatePhone=false;

	var msgPrefix=" ";
	var user_msg="";
	var emailfilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if(vFormObject.full_name.value=="") user_msg= user_msg + wrap(msgPrefix + "Full Name cannot be empty. Please check.");
	if(vFormObject.rbGender_Male.checked==false && vFormObject.rbGender_Female.checked==false) user_msg= user_msg + wrap("Please select the gender Brother or Sister.");
	if(vFormObject.dob.value=="")
	{
		
		user_msg = user_msg + wrap(msgPrefix + "Date of Birth cannot be empty. Please check.");
		
	}else
	{
		if($("dob_Year_ID").value>=Today.getFullYear()){
			user_msg= user_msg + wrap(msgPrefix + "Invalid Date of birth. Please check.");
		}
	}
	if(vFormObject.contact_address.value=="") user_msg= user_msg + wrap(msgPrefix + "Mailing/Contact Address cannot be empty. Please check.");
	if(vFormObject.reg_city.value=="") user_msg= user_msg + wrap(msgPrefix + "City cannot be empty. Please check.");
	if(vFormObject.reg_state.value=="") user_msg= user_msg + wrap(msgPrefix + "State cannot be empty. Please check.");
	if(vFormObject.telephone_number.value=="" && validatePhone==true) user_msg = user_msg + wrap(msgPrefix + "Telephone Number cannot be empty. Please check.");
	if(vFormObject.email_address.value=="" && validateEmail==true)	user_msg = user_msg + wrap("Email address cannot be empty. Please check.");
	
	

	if(vFormObject.email_address.value!="")
	{
		if (!emailfilter.test(vFormObject.email_address.value))
			 user_msg = user_msg + wrap("Invalid Email address. Please check.");
		else{
		
			if(!$('spEmailCheck').innerHTML==""){
				
				user_msg = user_msg + wrap("The emailId " + vFormObject.email_address.value + " already exists in the system. Please check.");
			
			}
		}
	}
	if(vFormObject.alternate_email.value!="")
	{
		if (!emailfilter.test(vFormObject.alternate_email.value)) 			user_msg = user_msg + wrap(msgPrefix + "Invalid alternate Email address. Please check.");

	}
	if(vFormObject.bk_center_email.value!="")
	{
		
		if (!emailfilter.test(vFormObject.bk_center_email.value)) user_msg = user_msg + wrap(msgPrefix + "Invalid BK Centre Email address. Please check.");

	}

	if(vFormObject.edu_qual.value=="") user_msg = user_msg + wrap(msgPrefix + "Educational Qualification cannot be empty. Please Check.");
	if(vFormObject.technical_specifications.value=="") user_msg = user_msg + wrap(msgPrefix + "Technical Specifications cannot be empty. Please check.");
			
	if(vFormObject.years_it_exp.value=="")
	{

		user_msg = user_msg + wrap("Please specify the experience.");
		if(!IsNumeric(vFormObject.years_it_exp.value))
		{
		//user_msg = user_msg + wrap(msgPrefix + "Please enter the years of experience in numbers.(1,1.2 etc)");
		}
		
	}

	if(vFormObject.are_you_bk_1.checked==false && vFormObject.are_you_bk_2.checked==false )	user_msg = user_msg + wrap("if you are not a BK, please select \"No\" in Are you BK? option");
	
	if(vFormObject.are_you_bk_1.checked==true){
	
	if(vFormObject.bk_center_address.value=="") user_msg= user_msg + wrap(msgPrefix + "Centre Address cannot be empty. Please check.");	
	
	
	
	}

	if(vFormObject.file_resume.value!=""){
		

	if(!(vFormObject.file_resume.value.indexOf(".pdf")>0 || vFormObject.file_resume.value.indexOf(".doc")>0) || vFormObject.file_resume.value.indexOf(".docx")>=0)
		user_msg=user_msg + "Curriculum Vitae  Resume File should be either a PDF File or Word Document File. The select file is not valid. Please Check.";
	
	}
	
		
	if(vFormObject.reg_technical_remark.value==""){
	
		user_msg=user_msg + "Skill set cannot be empty. Please check";
	
	}
	
	if(user_msg=="")
	{
		$("frmSubmit").disabled=true;
		$("frmSubmit").value="Processing please wait...";
		return true;
	}
	else
	{	
		alert(user_msg);
		return false;
	}



}



function showBKLayer(vMode)
{

	if(vMode==1)
	{
	
	$('are_you_bk_1').checked=true;
	$('are_you_bk_2').checked=false;
	$("dvAloukikDOB").show();


	$("dvCentrePhone").show();
	$("dvCentreEmail").show();
	$("dvCentreAddress").show();
	$("dvCentreInCharge").show();
	
	$("dvCentreType").show();
	$("dvSIG").show();
	
	
	}
	else
	{
	$('are_you_bk_2').checked=true;
	$('are_you_bk_1').checked=false;
	$("dvCentreAddress").hide();
	$("dvSIG").hide();
	$("dvCentreInCharge").hide();
	$("dvAloukikDOB").hide();
	$("dvCentreAddress").hide();
	$("dvCentrePhone").hide();
	$("dvCentreEmail").hide();
	$("dvCentreType").hide();
	
	}


}
function setState1(vState)
{
	if(vState=="Other")
		$("reg_state_other1").show();
	else
		$("reg_state_other1").hide();

}

function setState(vState)
{
	if(vState=="Other")
		$("reg_state_other").show();
	else
		$("reg_state_other").hide();

}
function setTechnicalEdu(vTech){


if(vTech=="Other")
		$("technical_specifications_other").show();
	else
		$("technical_specifications_other").hide();


}
function setEducation(vEducation)
{
	if(vEducation=="Other")
		$("edu_qual_other").show();
	else
		$("edu_qual_other").hide();

}
function setCountry(vCountry)
{
	if(vCountry=="Other")
		$("reg_country_other").show();
	else
		$("reg_country_other").hide();

}

function setCountry1(vCountry)
{
	if(vCountry=="Other")
		$("reg_country_other1").show();
	else
		$("reg_country_other1").hide();

}


function allowNumbersOnly(eventRef)
{

       var keyStroke = (eventRef.which) ? eventRef.which : (window.event) ? window.event.keyCode : -1;
       var returnValue = false;
           

      if ( ((keyStroke >= 48) && (keyStroke <= 57))) {
               returnValue = true;
       }
       if (keyStroke == 8 || keyStroke == -1 ||  keyStroke == 32){
               returnValue = true;
       }
       return returnValue;
}


function setSkillSetValues(){

var selValues="";
$$(".skillitem").each(function(vItem){
	if(vItem.checked){
	
		if(selValues!="")
			selValues=selValues + "," +  vItem.next().innerHTML ;
		else
			selValues=vItem.next().innerHTML ;
	
	}
	
	});
	
	if($("reg_technical_remark").value==""){
		$("reg_technical_remark").value=selValues;
	}else{
		if(selValues!="")	
		$("reg_technical_remark").value=$("reg_technical_remark").value + "," + selValues;
	}
	
}

function checkEmail(vEmailId,vMode){

var vUrl="validateinfo.php";
if(vMode==3) vUrl="../" + vUrl;

new Ajax.Request(vUrl + "?mode="+ vMode + "&email="+vEmailId, {
				method: 'get',
				onSuccess: function(req) {
					
					$('spEmailCheck').innerHTML=trim(req.responseText);
					
				}
			});
			

}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
var calOverrideCheck=0;
function  handleCalendar(){

	if(calOverrideCheck==1){
	refreshYears();
	
	}

}



function copyAddress(objChkState){

if(objChkState){

$("contact_address1").value=$("contact_address").value;
$("reg_city1").value=$("reg_city").value;
$("reg_state1").value=$("reg_state").value;
$("reg_zip1").value=$("reg_zip").value;
$("reg_country1").value=$("reg_country").value;


}else{

$("contact_address1").value="";
$("reg_city1").value="";
$("reg_state1").value="";
$("reg_zip1").value="";
$("reg_country1").value="";

}

}